package com.dhcc.bpm.modules.scf.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dhcc.bpm.common.segmentId.LocalCacheIdGenerator;
import com.dhcc.bpm.common.utils.StringUtils;
import com.dhcc.bpm.modules.scf.dto.ScfRenewableInInfoDTO;
import com.dhcc.bpm.modules.scf.dto.ScfRenewableOutInfoDTO;
import com.dhcc.bpm.modules.scf.entity.*;
import com.dhcc.bpm.modules.scf.entity.SelectEntity.RenewableOutByRenewableIn;
import com.dhcc.bpm.modules.scf.enumUtil.ScfOperationLogInfoEnum;
import com.dhcc.bpm.modules.scf.mapper.ScfContractInfoMapper;
import com.dhcc.bpm.modules.scf.mapper.ScfDriverInfoMapper;
import com.dhcc.bpm.modules.scf.mapper.ScfRenewableOutInfoMapper;
import com.dhcc.bpm.modules.scf.mapper.ScfSubjectBasicInfoMapper;
import com.dhcc.bpm.modules.scf.service.IScfFileAttachmentInfoService;
import com.dhcc.bpm.modules.scf.service.IScfOperationLogInfoService;
import com.dhcc.bpm.modules.scf.service.IScfRenewableInInfoService;
import com.dhcc.bpm.modules.scf.service.IScfRenewableOutInfoService;
import com.dhcc.bpm.modules.scf.util.ExcelUtil;
import com.dhcc.bpm.modules.scf.util.MD5Utils;
import com.dhcc.bpm.modules.scf.util.OBSUtil;
import com.dhcc.bpm.modules.scf.vo.ScfContractInfoVO.ScfGetContractDetailsVO;
import com.dhcc.bpm.modules.scf.vo.ScfDriverInfoVO.ScfGetDriverDetailsVO;
import com.dhcc.bpm.modules.scf.vo.ScfFileAttachmentInfoVO.ScfFileAttachmentInfoVO;
import com.dhcc.bpm.modules.scf.vo.ScfRenewableInInfoVO.ScfGetRenewableInDetailsVO;
import com.dhcc.bpm.modules.scf.vo.ScfRenewableOutInfoVO.ScfGetRenewableOutDetailsVO;
import com.dhcc.bpm.modules.scf.vo.ScfRenewableOutInfoVO.ScfGetRenewableOutListVO;
import com.dhcc.bpm.modules.scf.vo.ScfSubjectBasicInfoVO.ScfGetSubjectDetailsVO;
import com.dhcc.bpm.modules.system.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 再生资源出库单服务实现类
 *
 * @author liuguoting
 * @since 2023-09-22
 */
@Service
@Slf4j
public class ScfRenewableOutInfoServiceImpl extends ServiceImpl<ScfRenewableOutInfoMapper, ScfRenewableOutInfo> implements IScfRenewableOutInfoService {

    /**
     * 文件附件service接口
     */
    @Autowired
    private IScfFileAttachmentInfoService scfFileAttachmentInfoService;
    /**
     * id生成器
     */
    @Autowired
    private LocalCacheIdGenerator localCacheIdGenerator;
    /**
     * 合同信息mapper接口
     */
    @Autowired
    private ScfContractInfoMapper scfContractInfoMapper;
    /**
     * 主体信息mapper接口
     */
    @Autowired
    private ScfSubjectBasicInfoMapper scfSubjectBasicInfoMapper;
    /**
     * 司机信息mapper接口
     */
    @Autowired
    private ScfDriverInfoMapper scfDriverInfoMapper;
    /**
     * 再生资源入库单service接口
     */
    @Autowired
    private IScfRenewableInInfoService scfRenewableInInfoService;
    /**
     * 操作记录信息service接口
     */
    @Autowired
    private IScfOperationLogInfoService scfOperationLogInfoService;
    /**
     * 用户信息service接口
     */
    @Autowired
    private IUserService userService;
    /**
     * obs对象存储工具类
     */
    @Autowired
    private OBSUtil obsUtil;

    /**
     * 再生资源出库单分页列表查询
     *
     * @param page
     * @param scfRenewableOutInfo
     * @return
     */
    @Override
    public IPage<ScfGetRenewableOutListVO> selectScfRenewableOutInfoPage(IPage<ScfGetRenewableOutListVO> page, ScfRenewableOutInfoDTO scfRenewableOutInfo) {
        List<ScfGetRenewableOutListVO> scfGetRenewableOutListVOS;
        String isRelated = scfRenewableOutInfo.getIsRelated();
        if (isRelated != null && isRelated.equals("3")) {
            // 查询再生资源出库单分页列表数据--未关联
            scfGetRenewableOutListVOS = baseMapper.selectUnrelatedRenewableOutRecords(page, scfRenewableOutInfo);
        } else {
            // 查询再生资源出库单分页列表数据--全部
            scfGetRenewableOutListVOS = baseMapper.selectScfRenewableOutInfoPage(page, scfRenewableOutInfo);
        }


      /*  if(scfRenewableOutInfo.getCorrelation()==1){
            // 过滤属性 correlation 为 1 的元素
            scfGetRenewableOutListVOS = scfGetRenewableOutListVOS.stream()
                    .filter(vo -> vo.getCorrelation() == 1)
                    .collect(Collectors.toList());
        }else if(scfRenewableOutInfo.getCorrelation()==0){
            scfGetRenewableOutListVOS = scfGetRenewableOutListVOS.stream()
                    .filter(vo -> vo.getCorrelation() == 0)
                    .collect(Collectors.toList());
        }
*/

        // 判断分页列表中是否有数据
        if (scfGetRenewableOutListVOS.size() != 0) {
            // 遍历再生资源出库单列表
            for (ScfGetRenewableOutListVO scfGetRenewableOutListVO : scfGetRenewableOutListVOS) {
                // 获取合同的rowId
                String contractRowId = scfContractInfoMapper.selectRowIdByContractNum(scfGetRenewableOutListVO.getContractNum() ,scfRenewableOutInfo.getOrgCode() );
                if(contractRowId !=null){
                    // 获取合同详细信息
                    ScfGetContractDetailsVO details = scfContractInfoMapper.getDetails(contractRowId);
                    // 获取再生资源详情
                    ScfGetSubjectDetailsVO scfSubjectBasicInfoMapperDetailsRenewable = scfSubjectBasicInfoMapper.getDetails(details.getPartyANum());
                    if (details != null && scfSubjectBasicInfoMapperDetailsRenewable != null) {
                        // 获取利废企业详情
                        ScfGetSubjectDetailsVO scfSubjectBasicInfoMapperDetailsRecyclingName = scfSubjectBasicInfoMapper.getDetails(details.getPartyBNum());
                        // 设置再生出库单的再生资源名称字段
                        scfGetRenewableOutListVO.setRenewableName(scfSubjectBasicInfoMapperDetailsRenewable.getSubName());
                        // 设置再生出库单的利废企业名称字段
                        scfGetRenewableOutListVO.setRecyclingName(scfSubjectBasicInfoMapperDetailsRecyclingName.getSubName());
                    }
                }
            }
        }
        return page.setRecords(scfGetRenewableOutListVOS);
    }

    /**
     * 再生资源出库单详情查询
     *
     * @param scfRenewableOutInfo
     * @return
     */
    @Override
    public ScfGetRenewableOutDetailsVO getDetails(ScfRenewableOutInfoDTO scfRenewableOutInfo) {
        // 获取再生资源出库单详情信息
        ScfGetRenewableOutDetailsVO detail = baseMapper.getDetails(scfRenewableOutInfo.getRowId());
        if (detail != null) {
            // 获取与文件附件表关联的id
            String rowId = detail.getRowId();
            // 根据根据合同编号获取合同rowId
            String contractRowId = scfContractInfoMapper.selectRowIdByContractNum(detail.getContractNum()  , detail.getOrgCode());
            // 获取合同详细信息
            ScfGetContractDetailsVO detailsContract = scfContractInfoMapper.getDetails(contractRowId);
            // 从合同中获取再生及供应商主体编号并查询主体信息
            ScfGetSubjectDetailsVO scfSubjectBasicInfoMapperDetailsRenewable = scfSubjectBasicInfoMapper.getDetails(detailsContract.getPartyANum());
            if (scfSubjectBasicInfoMapperDetailsRenewable != null) {
                detail.setRenewableName(scfSubjectBasicInfoMapperDetailsRenewable.getSubName());

            }
            ScfGetSubjectDetailsVO scfSubjectBasicInfoMapperDetailsSupplierName = scfSubjectBasicInfoMapper.getDetails(detailsContract.getPartyBNum());
            if (scfSubjectBasicInfoMapperDetailsSupplierName != null) {
                // 从主体信息中拿到主体名称并赋值
                detail.setRecyclingName(scfSubjectBasicInfoMapperDetailsSupplierName.getSubName());
            }

            // 司机驾驶证号再去查询司机的详细信息
            String driverRowId = scfDriverInfoMapper.selectRowIdByLicense(detail.getLicense());
            ScfGetDriverDetailsVO scfDriverInfoMapperDetails = scfDriverInfoMapper.getDetails(driverRowId);
            // 取出司机姓名及司机联系方式并设置给入库单详情中
            detail.setDriverName(scfDriverInfoMapperDetails.getDriverName());
            detail.setDriverMobile(scfDriverInfoMapperDetails.getMobile());
            // 查询并设置再生出库单与再生入库单的对应的关联关系
            List<ScfGetRenewableInDetailsVO> renewableOutByRenewableIns = baseMapper.selectRenewableOutByRenewableInt(detail.getRenewableOutNum());

            detail.setRenewableOutByRenewableIns(renewableOutByRenewableIns);
//            }
            // 查询关联的附件信息
            List<ScfFileAttachmentInfoVO> scfFileAttachmentInfoVOS = scfFileAttachmentInfoService.selectAllByAssociationId(rowId);
            // 将附件信息存进dto里
            detail.setFileAttachmentInfoVOS(scfFileAttachmentInfoVOS);
        }
        return detail;
    }

    /**
     * 再生资源出库单新增
     *
     * @param scfRenewableOutInfo
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean saveRenewableOutInfo(ScfRenewableOutInfoDTO scfRenewableOutInfo) throws Exception {
        // 判断是否已存在该再生出库单号码
        String renewableOutNum = scfRenewableOutInfo.getRenewableOutNum();
        String rowIdByRenewableOutNum = baseMapper.selectRowIdByRenewableOutNum(renewableOutNum);
        if (rowIdByRenewableOutNum != null) {
            // 说明该再生出库单号码库中存在，抛出异常，提示该再生出库单已存在
            throw new Exception("再生企业出库单:" + renewableOutNum + "已存在，请勿重复录入出库单！");
        }
        // 生成日期
        SimpleDateFormat date = new SimpleDateFormat("YYYYMMdd");
        String formatdate = date.format(new Date());
        // 生成时间
        SimpleDateFormat timeFormat = new SimpleDateFormat("HHmmss");
        String formTime = timeFormat.format(new Date());
        // 生成ROW_ID
        String rowId = "RWCK" + localCacheIdGenerator.nextId() + formTime;
        // 开始补充对象字段start
        // 设置记录编号
        scfRenewableOutInfo.setRowId(rowId);
        // 设置登记日期
        scfRenewableOutInfo.setRecordDate(formatdate);
        // 设置登记时间
        scfRenewableOutInfo.setRecordTime(formTime);
        // 信息补充完成
        // 开始关联再生入库单
        List<RenewableOutByRenewableIn> renewableOutByRenewableIns = scfRenewableOutInfo.getRenewableOutByRenewableIns();
        // 不为空则说明该再生资源出库单新增时关联了再生入库单
        if (renewableOutByRenewableIns != null) {
            for (RenewableOutByRenewableIn renewableOutByRenewableIn : renewableOutByRenewableIns) {
                // 设置再生出库单编号
                renewableOutByRenewableIn.setRenewableOutNum(scfRenewableOutInfo.getRenewableOutNum());
                renewableOutByRenewableIn.setRenewableOutRowId(scfRenewableOutInfo.getRowId());
                // 设置再生入库rowId
                renewableOutByRenewableIn.setRenewableInRowId(renewableOutByRenewableIn.getRowId());
                // 设置再生出库关联关系的rowId
//                renewableOutByRenewableIn.setRowId("GL" + localCacheIdGenerator.nextId() + formTime);

                renewableOutByRenewableIn.setRowId("ZSCK_ZSRK" + MD5Utils.md5(renewableOutByRenewableIn.getRenewableOutNum() + renewableOutByRenewableIn.getRenewableInNum()));

//                renewableOutByRenewableIn.setRowId("GL" + localCacheIdGenerator.nextId() + formTime);
                // 保存再生出库与再生入库的关联关系
                baseMapper.saveRenewableOutByRenewableInt(renewableOutByRenewableIn);
            }
        }
        // 新增再生出库单信息
        boolean isSave = save(scfRenewableOutInfo);
        List<String> rowIds = scfRenewableOutInfo.getRowIds();
        // 设置合同文件存放路径
        String path = "RWCK" + "/" + rowId + "/";
        if (rowIds != null) {
            if (!rowIds.isEmpty()) {
                if (isSave) {
                    for (String fileRowId : rowIds) {
                        // 根据文件id获取文件的临时objectKey
                        String objectKeyOfTemp = scfFileAttachmentInfoService.getFilePath(fileRowId, null);
                        // 截取文件的名称
                        String extractFileName = obsUtil.extractFileName(objectKeyOfTemp);
                        // 拼接正式的objectKey
                        String objectKey = path + extractFileName;
                        // 将附件文件从临时目录转移到正式目录中
                        obsUtil.copyFile(objectKey, objectKeyOfTemp);
                        scfFileAttachmentInfoService.updateFilePath(fileRowId, objectKey);
                    }
                }
                // 补充对象字段结束end
                scfFileAttachmentInfoService.batchUpdateField(rowIds, rowId);
            }
        }
        // 生成日期时间
        SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String formattedDateTime = datetime.format(new Date());
        ScfOperationLogInfo scfOperationLogInfo = new ScfOperationLogInfo();
        // 根据用户id查询用户名称，重新赋值登记人字段
        List<Long> ids = new ArrayList<>();
        ids.add(Long.valueOf(scfRenewableOutInfo.getRecorder()));
        scfOperationLogInfo.setRecorder(userService.selectUserNameByIds(ids).get(0));
        scfOperationLogInfo.setOperationModule(ScfOperationLogInfoEnum.LOGISTICS.getOperation());
        scfOperationLogInfo.setOperationFunction("再生资源出库单");
        scfOperationLogInfo.setOperationType(ScfOperationLogInfoEnum.ADD.getOperation());
        scfOperationLogInfo.setOperationContent("新增一条再生资源出库单，再生资源出库单号：" + scfRenewableOutInfo.getRenewableOutNum());
        scfOperationLogInfo.setRecordDate(formattedDateTime);
        // 判断再生出库单新增是否成功
        if (isSave) {
            // 新增成功则记录操作日志记录
            scfOperationLogInfoService.saveOperationLogInfo(scfOperationLogInfo);
        }
        return isSave;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int bachSaveRenewableOutInfo(List<ScfRenewableOutInfo> scfRenewableOutInfos, String operatorId) {
        List<ScfRenewableOutInfo> scfRenewableOutInfoList = new ArrayList<>();
        List<ScfOperationLogInfo> scfOperationLogInfoList = new ArrayList<>();
        List<RenewableOutByRenewableIn> scfRenewableOutInfoRenewableInList = new ArrayList<>();


        for (ScfRenewableOutInfo scfRenewableOutInfo : scfRenewableOutInfos) {
            // 设置登记人ID
            scfRenewableOutInfo.setRecorder(operatorId);
            // 生成日期
            SimpleDateFormat date = new SimpleDateFormat("YYYYMMdd");
            String formatdate = date.format(new Date());
            // 生成时间
            SimpleDateFormat timeFormat = new SimpleDateFormat("HHmmss");
            String formTime = timeFormat.format(new Date());
            // 生成ROW_ID
            String rowId = "RWCK" + localCacheIdGenerator.nextId() + formTime;
            // 开始补充对象字段start
            // 设置记录编号
            scfRenewableOutInfo.setRowId(rowId);
            // 设置登记日期
            scfRenewableOutInfo.setRecordDate(formatdate);
            // 设置登记时间
            scfRenewableOutInfo.setRecordTime(formTime);
            // 信息补充完成


            // 判断是否已存在该再生出库单号码
            String renewableOutNum = scfRenewableOutInfo.getRenewableOutNum();
            String rowIdByRenewableOutNum = baseMapper.selectRowIdByRenewableOutNum(renewableOutNum);
            if (rowIdByRenewableOutNum == null) {
                scfRenewableOutInfoList.add(scfRenewableOutInfo);
                // 生成日期时间
                SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String formattedDateTime = datetime.format(new Date());
                ScfOperationLogInfo scfOperationLogInfo = new ScfOperationLogInfo();
                // 根据用户id查询用户名称，重新赋值登记人字段
                List<Long> ids = new ArrayList<>();
                ids.add(Long.valueOf(scfRenewableOutInfo.getRecorder()));
                scfOperationLogInfo.setRecorder(userService.selectUserNameByIds(ids).get(0));
                scfOperationLogInfo.setOperationModule(ScfOperationLogInfoEnum.LOGISTICS.getOperation());
                scfOperationLogInfo.setOperationFunction("再生资源出库单");
                scfOperationLogInfo.setOperationType(ScfOperationLogInfoEnum.ADD.getOperation());
                scfOperationLogInfo.setOperationContent("新增一条再生资源出库单，再生资源出库单号：" + scfRenewableOutInfo.getRenewableOutNum());
                scfOperationLogInfo.setRecordDate(formattedDateTime);
                scfOperationLogInfoList.add(scfOperationLogInfo);


                RenewableOutByRenewableIn zsck2zsrk = new RenewableOutByRenewableIn();
                zsck2zsrk.setRenewableInNum(scfRenewableOutInfo.getRenewableInNum());
                zsck2zsrk.setRenewableOutNum(scfRenewableOutInfo.getRenewableOutNum());
                zsck2zsrk.setRenewableOutRowId(scfRenewableOutInfo.getRowId());
                zsck2zsrk.setRenewableInRowId("no");
                zsck2zsrk.setRowId("ZSCK_ZSRK" + MD5Utils.md5(zsck2zsrk.getRenewableOutNum() + zsck2zsrk.getRenewableInNum()));
                zsck2zsrk.setOrgCode(scfRenewableOutInfo.getOrgCode());
                baseMapper.saveRenewableOutByRenewableInt(zsck2zsrk);
                scfRenewableOutInfoRenewableInList.add(zsck2zsrk);
            }
        }

        boolean saveBatch = saveBatch(scfRenewableOutInfoList);
        if (saveBatch) {
            scfOperationLogInfoService.bachSaveOperationLogInfo(scfOperationLogInfoList);
        }
        return scfRenewableOutInfoList.size();
    }

    /**
     * 再生资源出库单更新
     *
     * @param scfRenewableOutInfo
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateRenewableOutInfo(ScfRenewableOutInfoDTO scfRenewableOutInfo) {
        // 生成日期
        SimpleDateFormat date = new SimpleDateFormat("YYYYMMdd");
        String formatdate = date.format(new Date());
        // 生成时间
        SimpleDateFormat timeFormat = new SimpleDateFormat("HHmmss");
        String formTime = timeFormat.format(new Date());
        // 开始补充对象字段start
        // 补充对象字段结束end
        String rowId = scfRenewableOutInfo.getRowId();
        List<String> rowIds = scfRenewableOutInfo.getRowIds();
        // 设置出库单文件存放路径
        String path = "RWCK" + "/" + rowId + "/";
        if (rowIds != null) {
            if (rowIds.size() != 0) {
                if (rowId != null) {
                    // 取消旧文件与记录关联
                    scfFileAttachmentInfoService.updataFiledNull(rowId);
                    // 给上传的新文件添加关联编号
                    scfFileAttachmentInfoService.batchUpdateField(rowIds, rowId);
                    for (String fileRowId : rowIds) {
                        // 根据文件id获取文件的临时objectKey
                        String objectKeyOfTemp = scfFileAttachmentInfoService.getFilePath(fileRowId, null);
                        // 截取文件的名称
                        String extractFileName = obsUtil.extractFileName(objectKeyOfTemp);
                        // 拼接正式的objectKey
                        String objectKey = path + extractFileName;
                        // 将附件文件从临时目录转移到正式目录中
                        obsUtil.copyFile(objectKey, objectKeyOfTemp);
                        scfFileAttachmentInfoService.updateFilePath(fileRowId, objectKey);
                    }
                }
            }
        }
        // 开始关联再生入库单
        List<RenewableOutByRenewableIn> renewableOutByRenewableIns = scfRenewableOutInfo.getRenewableOutByRenewableIns();
        if (renewableOutByRenewableIns != null) {
            // 清理旧的关联关系记录，然后建立新的关联关系
            baseMapper.deleteRenewableOutByRenewableInt(scfRenewableOutInfo.getRenewableOutNum());
            for (RenewableOutByRenewableIn renewableOutByRenewableIn : renewableOutByRenewableIns) {
                // 设置再生出库单编号
                renewableOutByRenewableIn.setRenewableOutNum(scfRenewableOutInfo.getRenewableOutNum());
                renewableOutByRenewableIn.setRenewableOutRowId(scfRenewableOutInfo.getRowId());
                // 设置再生入库rowId
                renewableOutByRenewableIn.setRenewableInRowId(renewableOutByRenewableIn.getRowId());
                // 设置再生出库关联关系的rowId
//                renewableOutByRenewableIn.setRowId("ZSCK_ZSRK" + localCacheIdGenerator.nextId() + formTime);
                renewableOutByRenewableIn.setRowId("ZSCK_ZSRK" + MD5Utils.md5(renewableOutByRenewableIn.getRenewableOutNum() + renewableOutByRenewableIn.getRenewableInNum()));


                // 保存再生出库与再生入库的关联关系
                baseMapper.saveRenewableOutByRenewableInt(renewableOutByRenewableIn);
            }
        }
        // 更新再生出库单
        boolean update = updateById(scfRenewableOutInfo);
        // 记录操作日志
        // 生成日期时间
        SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String formattedDateTime = datetime.format(new Date());
        ScfOperationLogInfo scfOperationLogInfo = new ScfOperationLogInfo();
        scfOperationLogInfo.setRowId("Log" + formatdate + formTime + localCacheIdGenerator.nextId());
        // 根据用户id查询用户名称，重新赋值登记人字段
        List<Long> ids = new ArrayList<>();
        ids.add(Long.valueOf(scfRenewableOutInfo.getRecorder()));
        scfOperationLogInfo.setRecorder(userService.selectUserNameByIds(ids).get(0));
        scfOperationLogInfo.setOperationModule(ScfOperationLogInfoEnum.LOGISTICS.getOperation());
        scfOperationLogInfo.setOperationFunction("再生资源出库单");
        scfOperationLogInfo.setOperationType(ScfOperationLogInfoEnum.UPDATE.getOperation());
        scfOperationLogInfo.setOperationContent("更新一条再生资源出库单，再生资源出库单号：" + scfRenewableOutInfo.getRenewableOutNum());
        scfOperationLogInfo.setRecordDate(formattedDateTime);
        // 判断再生出库单更新是否成功
        if (update) {
            // 成功则记录操作日志
            scfOperationLogInfoService.saveOperationLogInfo(scfOperationLogInfo);
        }
        return update;
    }

    /**
     * 再生资源出库单批量导入
     *
     * @param operatorId
     * @param file
     * @return
     * @throws IOException
     */
    @Override
    public List<ScfRenewableOutInfo> batchSaveRenewableOutInfo(String operatorId, MultipartFile file) throws IOException {
        // 获取文件的Base64编码
        byte[] fileBytes = file.getBytes();
        // 解析excel文件获取数据集合
        List<ScfRenewableOutInfoExtend> scfRenewableOutInfos = ExcelUtil.readExcel(fileBytes, ScfRenewableOutInfoExtend.class, "再生资源企业出库单", 3);
        List<ScfRenewableOutInfo> list1 = new ArrayList<>();
        for (ScfRenewableOutInfoExtend orig : scfRenewableOutInfos) {
            ScfRenewableOutInfo dest = new ScfRenewableOutInfo();
            try {
                orig.setSettlementAmount(orig.getJiesuan());
                BeanUtils.copyProperties(dest, orig);
                list1.add(dest);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            } catch (InvocationTargetException e) {
                throw new RuntimeException(e);
            }
        }

        return list1;
    }

    @Override
    public Boolean deleteByIds(String[] ids) {
        return this.baseMapper.deleteByIds(ids);
    }
}
